package cc.atliberty.structural.composite.ex1;

import java.util.ArrayList;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-31 08:16
 * @description: 文件夹节点
 */
public class DirectoryNode {
    String nodeName;

    public DirectoryNode(String nodeName) {
        this.nodeName = nodeName;
    }
    
    ArrayList<DirectoryNode> nodeList =  new ArrayList<>();
    ArrayList<FileLeaf> leafList = new ArrayList<>();
    
    public void addNode(DirectoryNode node) {
        nodeList.add(node);
    }
    public void addLeaf(FileLeaf fileLeaf) {
        leafList.add(fileLeaf);
    }
    
    public void display(){
        for (int i = 0; i < leafList.size(); i++) {
            leafList.get(i).display();
        }
        for (int i = 0; i < nodeList.size(); i++) {
            System.out.println(nodeList.get(i).nodeName);
            nodeList.get(i).display();
        }
    }
}
